﻿<?php
/**
 * giaovien View for giaovien World Component
 * 
 * @package    Joomla.Tutorials
 * @subpackage Components
 * @link http://dev.joomla.org/component/option,com_jd-wiki/Itemid,31/id,tutorials:components/
 * @license		GNU/GPL
 */

jimport( 'joomla.application.component.view');

/**
 * HTML View class for the giaovienWorld Component
 *
 * @package		Joomla.Tutorials
 * @subpackage	Components
 */
class GiaoVienViewManage extends JView
{

	function display($tpl = null)
	{
	$giaovien        =& $this->get('Data'); 
	//echo $giaovien->magv;
    $isNew        = ($giaovien->magv == null); 
    $text = $isNew ? JText::_( 'New' ) : JText::_( 'Edit' ); 
    JToolBarHelper::title(   JText::_( 'Quản lý giáo viên hướng dẫn' ).': <small><small>[ ' . $text.' ]</small></small>' ); 
    JToolBarHelper::save(); 
    if ($isNew)  { 
        JToolBarHelper::cancel(); 
    } else { 
        // for existing items the button is renamed `close` 
        JToolBarHelper::cancel( 'cancel', 'Close' ); 
    } 
	/*Create list of classs*/	
		global $mainframe, $option;	
		$filter_nganh= $mainframe->getUserStateFromRequest( $option.'filter_nganh',		'filter_nganh', 		'',			'string' );	
		if($text=="Edit")
			$filter_nganh=$giaovien->manganh;
			
		$db	=& JFactory::getDBO();
		$query = 'SELECT manganh AS value, tennganh AS text'
			. ' FROM #__nganh'
		;
		$db->setQuery( $query );
		$types[] = JHTML::_('select.option',  '', '- '. JText::_( 'Chọn ngành' ) .' -' );
		foreach( $db->loadObjectList() as $obj )
		{
			$types[] = JHTML::_('select.option',  $obj->value, JText::_( $obj->text ) );
		}
		$lists['type'] 	= JHTML::_('select.genericlist',   $types, 'filter_nganh', 'class="inputbox" size="1" 
		onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_nganh" );
		/* End */	
		
		/*Create list of phan nganh*/	
		$where='';
		if($filter_nganh!='')
			$where='where manganh=\''.$filter_nganh.'\'';
		$query = 'SELECT *'
			. ' FROM #__phan_nganh '.$where;
		;
		$db->setQuery( $query );
		
		/* End */
		$this->assignRef('phannganh',$db->loadObjectList());
		$this->assignRef('giaovien', $giaovien); 	
		$this->assignRef('text', $text);
		$this->assignRef('lists',$lists);
        parent::display($tpl); 
    } 
}
?>